package org.javaforever.gatescore.shiroauth.verb;

import java.util.ArrayList;
import java.util.List;

import org.javaforever.gatescore.core.FrontCodeBlock;
import org.javaforever.gatescore.core.FrontDomain;
import org.javaforever.gatescore.core.FrontMethod;
import org.javaforever.gatescore.core.FrontVerb;
import org.javaforever.gatescore.core.Statement;
import org.javaforever.gatescore.core.Writeable;
import org.javaforever.gatescore.core.WriteableUtil;
import org.javaforever.gatescore.utils.StringUtil;

public class LogoutUser extends FrontVerb {
	
	public LogoutUser(FrontDomain domain) {
		super();
		this.domain = domain;
		this.verbName = "Logout"+this.domain.getStandardName();
	}

	@Override
	public FrontMethod generateControllerMethod() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public FrontMethod generateApiMethod() throws Exception {
		FrontMethod method = new FrontMethod();
		method.setStandardName("logout" + StringUtil.capFirst(this.domain.getStandardName()));
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"export function logout() {"));
		sList.add(new Statement(2000L,1,"return request({"));
		sList.add(new Statement(3000L,2,"url: '/login"+this.domain.getControllerNamingSuffix()+"/logout"+this.domain.getCapFirstDomainName()+"',"));
		sList.add(new Statement(4000L,2,"method: 'get'"));
		sList.add(new Statement(5000L,1,"})"));
		sList.add(new Statement(6000L,0,"}"));
		method.setMethodStatementList(WriteableUtil.merge(sList));
		return method;
	}

	@Override
	public FrontCodeBlock generateRouteBlockBlock() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public FrontMethod generateControllerMethod(String indexSuffix) throws Exception {
		return generateControllerMethod();
	}
}
